package com.tcc.fastline.Helpers;

import java.util.List;

import com.tcc.fastline.Domain.*;
import com.tcc.smartqueue.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GridViewEstabelecimentoAdapter extends BaseAdapter{

	private final Context context;
	private final List<Estabelecimento> values;

	public GridViewEstabelecimentoAdapter(Context context, List<Estabelecimento> values) {
		this.context = context;
		this.values = values;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View rowView = inflater.inflate(R.layout.list_estabelecimento_item, parent, false);

		TextView textViewNomeEstabelecimento = (TextView) rowView.findViewById(R.id.label_NomeEstabelecimento);
		TextView textViewEndereco = (TextView) rowView.findViewById(R.id.label_endereco);
		ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
		
		textViewNomeEstabelecimento.setText(values.get(position).getNome());
		textViewEndereco.setText(values.get(position).getEndereco().getEnderecoComercial() + " " + values.get(position).getEndereco().getComplemento());
		imageView.setImageResource(R.drawable.ic_usuario);
		
		if(position % 2 == 0){
			rowView.setBackgroundColor(Color.LTGRAY);
		}
		else{
			rowView.setBackgroundColor(Color.WHITE);
		}
		
		return rowView;
	}

	@Override
	public int getCount() {
		return this.values.size();
	}

	@Override
	public Object getItem(int position) {
		return this.values.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
}
